package com.eve.util;

import java.text.DecimalFormat;

/**
 * @author: ivan.yao<haif.yao@gmail.com>
 * @date: 16/7/10.
 */
public class NumberHelper {

    public static final String NORMAL_FORMAT = "###.##";

    public static String normalFormat(Object object){
        return new DecimalFormat(NORMAL_FORMAT).format(object);
    }

    public static long parseLong(String str){

        try{
            return Long.valueOf(str);
        }catch (NumberFormatException e){
            return 0l;
        }
    }

    public static float parseFloat(String str){

        try{
            return Float.valueOf(str);
        }catch (NumberFormatException e){
            return 0f;
        }
    }
}
